#include <stdio.h>
typedef unsigned float_bits;
float_bits float_i2f(int i)
{
 unsigned sign=0;
   unsigned exp=0;
   if(i<0)
    {
       i=-i;
       sign=1;
    }

   unsigned frac=i;
   i=i|(i>>1);
   i=i|(i>>2);
   i=i|(i>>4);
   i=i|(i>>8);
   i=i|(i>>16);
   i=i^(i>>1);
   frac=(frac-i);
   while(i>>=1)
    exp++;
   frac=(frac<<(23-exp)) & 0xFFFFFFFF;
   exp+=127;
   sign=sign & 1;
    exp=exp& 0xFF;
   printf("exp=%d\t frac=%d\t i=%d\t",exp,frac,i);
    return(sign<<31)|(exp<<23)|frac;
}

int main(){
int x;
int i;
char c;
for(i=0;;i++){
printf("input your num:");
scanf("%d",&x);
printf("your num is %d,float_i2f is %u,(float) is %f\n",x,float_i2f(x),(float)x);
printf("do you want to continue?(y or no)\n");
getchar();
scanf("%c",&c);
if(c=='n') break;
else continue;
}
}

